package com.travelranking.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@Entity
@Table(name="CITY")
@NamedQueries({
	@NamedQuery(name="getAllCity", query="from CityEntity ce order by ce.name asc"),
	@NamedQuery(name="getCityByCountry", query="from CityEntity ce where ce.country = :country order by ce.name asc")
	//,@NamedQuery(name="getCities", query="from CityEntity ce inner join fetch ce.country ctry WHERE crty.id = :idCountry")
})

public class CityEntity implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private Long id;
	private String name;
	private CountryEntity country;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	} 
	
	@Column(name="NAME")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToOne(targetEntity=CountryEntity.class)
	public CountryEntity getCountry() {
		return country;
	}
	public void setCountry(CountryEntity country) {
		this.country = country;
	}

}
